﻿using System;
using UnityEngine;
using UnityEngine.Rendering;

// Token: 0x020000A1 RID: 161
[RequireComponent(typeof(Camera))]
[ExecuteInEditMode]
public class CommandBuffet_ClearColorOnly : MonoBehaviour
{
	// Token: 0x0600051E RID: 1310 RVA: 0x0001E574 File Offset: 0x0001C774
	private void Cleanup()
	{
		if (this.cam != null && this.buf != null)
		{
			this.cam.RemoveCommandBuffer(this.camEvent, this.buf);
			this.buf.Release();
			this.buf = null;
		}
	}

	// Token: 0x0600051F RID: 1311 RVA: 0x0001E5C8 File Offset: 0x0001C7C8
	public void OnEnable()
	{
		this.Cleanup();
	}

	// Token: 0x06000520 RID: 1312 RVA: 0x0001E5D0 File Offset: 0x0001C7D0
	public void OnDisable()
	{
		this.Cleanup();
	}

	// Token: 0x06000521 RID: 1313 RVA: 0x0001E5D8 File Offset: 0x0001C7D8
	public void OnPreRender()
	{
		if (!base.gameObject.activeInHierarchy || !base.enabled)
		{
			this.Cleanup();
			return;
		}
		if (this.buf != null)
		{
			return;
		}
		if (this.cam == null)
		{
			this.cam = base.GetComponent<Camera>();
		}
		this.buf = new CommandBuffer();
		this.buf.name = "clear color only";
		this.buf.ClearRenderTarget(false, true, this.clearColor);
		this.cam.AddCommandBuffer(this.camEvent, this.buf);
	}

	// Token: 0x04000417 RID: 1047
	public Color clearColor;

	// Token: 0x04000418 RID: 1048
	public CameraEvent camEvent = CameraEvent.BeforeGBuffer;

	// Token: 0x04000419 RID: 1049
	private Camera cam;

	// Token: 0x0400041A RID: 1050
	private CommandBuffer buf;
}
